package xju.ssm_13_14.config;

import org.springframework.context.annotation.*;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

@Configuration
@ComponentScan({"xju.ssm_13_14.service","xju.ssm_13_14.mapper"})
@EnableAspectJAutoProxy
@EnableTransactionManagement
@Import({DataSourceConfig.class, MybatisConfig.class})
public class SpringConfig {

    // 事务管理器
    @Bean
    public TransactionManager transactionManager(DataSource dataSource) {
        DataSourceTransactionManager transactionManager = new DataSourceTransactionManager();
        transactionManager.setDataSource(dataSource);
        return transactionManager;
    }
}
